<template>
	<view>
		<u-navbar placeholder fixed bgColor="#21B4F3" leftIconColor="#fff" autoBack>
			<view slot="center" style="font-size: 16px;color: #FFFFFF;">人员</view>
			<!-- 原型没有 -->
			<!-- <view slot="right"><u--image src="/static/icon/icon-54.png" width="42rpx" height="42rpx"></u--image></view> -->
		</u-navbar>
		<view class="center">
			<view class="content d-p-30">
				<view class="sub-title d-font-30" style="color: #0882F3;">人员情况概况</view>
				<view class="d-flex d-text-center d-p-t-30">
					<view class="d-flex-1">
						<view style="font-weight: bold;font-size: 54rpx;">{{ spc ? spc.common : 0 }}</view>
						<view class="d-font-24" style="color: #162233;">一般作业人员数量</view>
					</view>
					<view class="d-flex-1">
						<view style="font-weight: bold;font-size: 54rpx;">{{ spc ? spc.special : 0 }}</view>
						<view class="d-font-24" style="color: #162233;">特种作业人员数量</view>
					</view>
				</view>
			</view>
		</view>
		<u-gap height="110rpx" bgColor="#ffffff"></u-gap>
		<view class="d-p-30">
			<view class="d-m-t-20"><text class="d-font-36" style="font-weight: bold;">应用功能</text></view>
			<view class="d-flex d-m-t-32">
				<view class="d-flex-1" @click="realName"><u--image src="/static/image/shiming.png" width="330rpx" height="130rpx" radius="10rpx"></u--image></view>
				<view class="d-flex-1 d-m-l-30" @click="transfer"><u--image src="/static/image/diaogang.png" width="330rpx" height="130rpx" radius="10rpx"></u--image></view>
			</view>

			<template v-if="list && list.length > 0">
				<view class="d-m-t-50"><text class="d-font-36" style="font-weight: bold;">人员列表</text></view>
				<view class="d-m-t-30">
					<view class="d-m-b-30 card d-p-30" v-for="(item, index) in list" :key="index" @click="memberDetail(item)">
						<view class="d-flex">
							<view class="d-font-28 u-line-1" style="font-weight: bold;color: #151C24;max-width: 280rpx;">{{ item.xm }}</view>
							<view class="d-font-28 d-m-l-70" style="color: #5D6672;">{{ item.xb }}</view>
							<view class="d-m-l-20 d-m-r-20"><u-line direction="col" length="36rpx" color="#DFDFDF"></u-line></view>
							<view class="tag d-flex">{{ item.smrz }}</view>
							<view class="d-m-l-20 d-m-r-20"><u-line direction="col" length="36rpx" color="#DFDFDF"></u-line></view>
							<view class="d-font-28" style="color: #21A5F3;">{{ item.ryzt }}</view>
						</view>
						<view class="d-flex d-font-24 d-m-t-20">
							<view style="color: #5D6672;">项目名称</view>
							<view class="d-flex-1 d-p-l-10 u-line-1" style="color: #162233;">{{ item.gcmc }}</view>
						</view>
						<view class="d-flex d-font-24 d-m-t-20">
							<view class="d-flex u-line-1" style="flex: 3;">
								<view class="d-m-r-10" style="color: #5D6672;">公民身份号码</view>
								<view style="color: #162233;">{{ item.zjhm || '无数据源' | str }}</view>
							</view>
							<view class="d-flex" style="flex: 2;">
								<view class="d-m-r-10" style="color: #5D6672;">所属区划</view>
								<view style="color: #162233;">{{ item.districtName || '无数据源' }}</view>
							</view>
						</view>
						<view class="d-flex d-font-24 d-m-t-20">
							<view class="d-flex" style="flex: 3;">
								<view class="d-m-r-10" style="color: #5D6672;">班组名称</view>
								<view class="d-flex-1" style="color: #162233;">{{ item.bzmc || '无数据源' }}</view>
							</view>
							<view class="d-flex" style="flex: 2;">
								<view class="d-m-r-10" style="color: #5D6672;">从事工种</view>
								<view style="color: #162233;">{{ item.zwzc || '无数据源' }}</view>
							</view>
						</view>
						<view class="d-flex d-font-24 d-m-t-20">
							<view class="d-flex" style="flex: 3;">
								<view class="d-m-r-10" style="color: #5D6672;">当天考勤</view>
								<view style="color: #ADB4BD;">{{ item.attendance || '无数据源' }}</view>
							</view>
							<view class="d-flex" style="flex: 2;">
								<view class="d-m-r-10" style="color: #5D6672;">本月工资</view>
								<view style="color: #ADB4BD;">{{ item.salary || '无数据源' }}</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<template v-else>
				<view style="padding: 10vh;"><u-empty icon="/static/image/none.png" text="暂无数据"></u-empty></view>
			</template>
		</view>
	</view>
</template>

<script>
import { getSpc, getStaff } from '../../../common/api.js';
export default {
	data() {
		return {
			spc: null,
			pageNum: 1,
			pageSize: 20,
			pageLast: 1,
			list: []
		};
	},
	onLoad() {
		this.init();
	},
	onReachBottom() {
		if (this.pageNum < this.pageLast) {
			++this.pageNum;
			this.getStaff().then(e => {
				this.list = this.list.concat(e.data);
			});
		}
	},
	methods: {
		init() {
			uni.showLoading({
				title: '加载中...',
				mask: true
			});
			getSpc({
				params: {
					bzbh: this.$user.ssgcxx[this.$appIndex].bzid // 班组id
				}
			}).then(e => {
				this.spc = e.data;
				this.pageNum = 1;
				this.getStaff().then(e => {
					this.list = e.data;
					this.pageLast = Math.ceil(e.total / this.pageSize);
					uni.hideLoading();
				});
			});
		},
		getStaff() {
			return getStaff({
				params: {
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					bzid: this.$user.ssgcxx[this.$appIndex].bzid, // 班组id
					rybh: this.$user.ssgcxx[this.$appIndex].rybh // 人员id
				}
			});
		},
		memberDetail(item) {
			uni.$u.route({
				url: '/pages/index/member/memberDetail',
				params: {
					id: item.id
				}
			});
		},
		realName() {
			// 实名
			uni.$u.route({
				url: '/pages/index/member/realName'
			});
		},
		transfer() {
			// 调岗
			uni.$u.route({
				url: '/pages/index/member/transfer'
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #fbfcfc;
}
.center {
	height: 200rpx;
	background-color: #21b4f3;
	position: relative;
	.content {
		width: 690rpx;
		height: 264rpx;
		background: #fefffe;
		box-shadow: 0rpx 5rpx 10rpx rgba(230, 230, 230, 0.6);
		border-radius: 16rpx;
		position: absolute;
		left: 30rpx;
		right: 30rpx;
		margin: auto;
		box-sizing: border-box;
		top: 30rpx;
		.sub-title {
			position: relative;
			padding-left: 20rpx;
			&::before {
				content: '';
				position: absolute;
				left: 0;
				top: 0;
				width: 8rpx;
				height: 22rpx;
				background: #13a4fe;
				border-radius: 4rpx;
				bottom: 0;
				margin: auto;
			}
		}
	}
}
.card {
	box-shadow: 0rpx 5rpx 10rpx rgba(0, 0, 0, 0.05);
	border-radius: 10rpx;
	background-color: #ffffff;
	.tag {
		height: 32rpx;
		background: #ffb61d;
		border-radius: 4rpx;
		color: #ffffff;
		font-size: 20rpx;
		padding: 0 10rpx;
	}
}
</style>
